﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;

namespace MobileSales.Model.Params
{
    [DataContract]
    public class DictionaryParam : Dictionary<string,string>
    {
        #region Parse
        public static DictionaryParam Parse(string value)
        {
            DictionaryParam dict = new DictionaryParam();
            string[] keyValueStrings = value.Split(';');
            foreach (var kv in keyValueStrings)
            {
                string[] keyValArr = kv.Split('=');
                if (keyValArr.Length != 2)
                    throw new FormatException();
                dict.Add(keyValArr[0], keyValArr[1]);
            }
            return dict;
        } 
        #endregion
    }
}
